package com.example.asapp.demo.chat;

import com.example.asapp.socket.WebSocketServer;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;
@RestController
@Slf4j
@RequestMapping("/api/demo/chat")
public class ChatApi {

    @Autowired
    ChatService chatService;

    @GetMapping("listQuery")
    public List<Chat> findAll(){
        return chatService.findAll();
    }

    @PostMapping("save")
    public Chat saveOne(@RequestBody Chat chat){
        return chatService.saveOne(chat);
    }

    @DeleteMapping("delete/{id}")
    public void deleteOne(@PathVariable String id){
       chatService.deleteByPrimary(id);
    }




}
